package com.bao.work;

import java.util.Scanner;

/**
 * @author baoye
 * @date 2024-07-24/19:04
 */
public class StringClass08 {
    public static void main(String[] args) {
        User[] users=new User[5];
        users[0]=new User("狗一","gou1");
        users[1]=new User("狗二","gou2");
        users[2]=new User("狗三","gou3");
        users[3]=new User("狗四","gou4");
        users[4]=new User("狗五","gou5");
        boolean flag=false;
        int index=-1;
        System.out.println("请输入用户名");
        String name=new Scanner(System.in).next();
        for (int i=0;i<users.length;i++) {
            if(users[i].userName.equals(name)){
                index=i;
                flag=true;
                break;
            }
        }
        if(!flag){
            System.out.println("用户名不存在");
            return;
        }
        System.out.println("请输入密码");
        if(!users[index].password.equals(new Scanner(System.in).next())){
            System.out.println("密码错误");
            return;
        }
        System.out.println("登录成功");
    }
}
class User{
    public String userName;
    public String password;

    public User(String userName, String password) {
        this.userName = userName;
        this.password = password;
    }
}
